package com.eclipse.training.models;

import java.util.ArrayList;

public class ModelContainer extends BaseModelElement {

	public ModelContainer(String name) {
		super(name);
	}

	ArrayList<BaseModelElement> elements = new ArrayList<BaseModelElement>();

	public ArrayList<BaseModelElement> getElements() {
		return elements;
	}

	public void setElements(ArrayList<BaseModelElement> elements) {
		this.elements = elements;
	}

	@Override
	public String toString() {
		return super.toString();
	}

	public void remove(BaseModelElement element) {
		if (elements.contains(element))
			elements.remove(element);
		else {
			for (BaseModelElement child : elements) {
				if (child instanceof ModelContainer)
					((ModelContainer) child).remove(element);
			}
		}
	}

}
